package personnel.department.dao.entity;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.apache.commons.lang3.time.DateUtils;

@Entity
@Table(name="quit")
public class Quit implements UniqueObject {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id")
	private Long id;
	
	@Column(name="date_quit")
	private Date dateQuit;
	
	@Column(name="number_order")
	private Integer numberOrder;
	
	@Column(name="cause_of_quit")
	private String causeOfQuit;
	
	@OneToOne(cascade=CascadeType.ALL)
	private Work work;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="employee_Id")
	private Employee employee;
	
	public Quit() {
	}
	
	public Quit(List<Object> params) {
		this.dateQuit = (Date) params.get(0);
		this.numberOrder = Integer.parseInt((String) params.get(1));
		this.causeOfQuit = ((String) params.get(2));
		Work work = new Work();
		work.setBaseWork((String) params.get(3));
		work.setExternalWork((String) params.get(4));
		work.setInternalWork((String) params.get(5));
		this.work = work;
	}

	public Long getId() {
		return id;
	}

	public Date getDateQuit() {
		return dateQuit;
	}

	public Integer getNumberOrder() {
		return numberOrder;
	}

	public String getCauseOfQuit() {
		return causeOfQuit;
	}

	public Work getWork() {
		return work;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setDateQuit(Date dateQuit) {
		this.dateQuit = dateQuit;
	}

	public void setNumberOrder(Integer numberOrder) {
		this.numberOrder = numberOrder;
	}

	public void setCauseOfQuit(String causeOfQuit) {
		this.causeOfQuit = causeOfQuit;
	}

	public void setWork(Work work) {
		this.work = work;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	
}
